<template>
    <div
        style="background-color: rgb(241, 241, 241);padding:5px;padding-right: 7px;min-height: 100vh; box-sizing: border-box;">
        <van-nav-bar title="修改密码" left-text="返回" left-arrow fixed @click="$router.push(`/user`)">
        </van-nav-bar>
        <div style="height: 55px;"></div>
        <van-form @submit="onSubmit">
            <van-cell-group inset>
                <van-field v-model="secret_answer" name="secret_answer" label="密保" placeholder="密保"
                    :rules="[{ required: true, message: '请填密保' }]" />

                <van-field v-model="password" type="password" name="password" label="新密码" placeholder="新密码"
                    :rules="[{ required: true, message: '请填写密码' }]" />
            </van-cell-group>
            <div style="margin: 16px;">
                <van-button round block type="primary" native-type="submit">
                    提交
                </van-button>
            </div>
        </van-form>

    </div>
</template>

<script setup>
import {ref} from 'vue'
import { editPassword } from '../../api';
import { showSuccessToast, showFailToast } from 'vant';

let password = ref('')
let secret_answer = ref('')

function onSubmit(form){
   editPassword(form).then(res=>{
    if(res.code==1){
        showSuccessToast('修改成功')
    }
   })
}
</script>